| Conditions | 2 |
| Total Lines | 11 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { localizedField, localizedFieldNonNull } from "../models/app"; |
||
| 41 | |||
| 42 | export function matchValueToModel<T>( |
||
| 43 | locale: Locales, |
||
| 44 | field: TranslatableKeys<T>, |
||
| 45 | value: string, |
||
| 46 | possibilities: T[], |
||
| 47 | ): T | null { |
||
| 48 | const matching = possibilities.filter( |
||
| 49 | (model) => localizeField(locale, model, field) === value, |
||
| 50 | ); |
||
| 51 | return matching.length > 0 ? matching[0] : null; |
||
| 52 | } |
||
| 53 |